package com.jshop.common.utils;

import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.ReUtil;

import java.util.Calendar;
import java.util.Date;

/**
 * @description: 订单编号生成器
 * @author: Mr.F
 * @create: 2019-09-10 11:27
 **/
public class OrderSnUtils {

    /**
     * 生成订单的编号order_sn
     */
    public static String generateOrderNumber() {
        Calendar cal = Calendar.getInstance();
        cal.setTime(new Date());
        String timeStr = DateUtils.format(cal.getTime(), DateUtils.DATE_TIME_PATTERN_YYYY_MM_DD_HH_MM_SS_SSS);
        return timeStr + CharUtil.getRandomNum(6);
    }

    /**
     * 生成售后订单号
     * @param
     * @return
     */
    public static String refundOrderNumber() {
        Calendar cal = Calendar.getInstance();
        cal.setTime(new Date());
        String timeStr = DateUtils.format(cal.getTime(), DateUtils.DATE_TIME_PATTERN_YYYY_MM_DD_HH_MM_SS_SSS);
        return "999"+timeStr + CharUtil.getRandomNum(6);
    }


    /**
     * 生成优惠价的
     * 编号Code
     */
    public static String CouponNumber() {
        return  CharUtil.getRandomString(8);
    }

    /*
    *  凭证码 Code
    */
    public static String OrderCode(){
        return  CharUtil.getRandomNum(6);
    }



}
